#include <iostream>
#include <deque>
#include <sstream>
#include <vector>

void parse(std::string s, std::vector<int> &num_vec)
{
    std::istringstream iss(s);

    std::string tok;
    while (std::getline(iss, tok, ','))
    {
        num_vec.push_back(std::stoi(tok));
    }
}

int main()
{
    std::string s;
    std::getline(std::cin, s);
    std::vector<int> input_vec;
    parse(s, input_vec);

    std::string k;
    std::getline(std::cin, k);
    std::vector<int> output_vec;
    parse(k, output_vec);

    std::string output_str = "";
    std::deque<int> deq;
    int j = 0;

    for (int i = 0; i < output_vec.size(); i++)
    {
        int m = output_vec[i];
        bool suc = true;
        while (suc)
        {
            if (deq.size() && deq.front() == m)
            {
                deq.pop_front();
                output_str += "L";
                break;
            }
            else if (deq.size() && deq.back() == m)
            {
                deq.pop_back();
                output_str += "R";
                break;
            }
            else if (j < input_vec.size())
            {
                deq.push_back(input_vec[j]);
                j++;
            }
            else
            {
                suc = false;
            }
        }
        if (!suc)
        {
            break;
        }
    }

    if (output_str.size() != input_vec.size())
    {
        std::cout << "NO" << std::endl;
    }
    else
    {
        std::cout << output_str << std::endl;
    }
    return 0;
}